package com.snail.utils;

import lombok.Data;

// 字幕条目类
@Data
public class SubtitleEntry {
    int index;
    String startTime;
    String endTime;
    String text;

    public SubtitleEntry(int index, String startTime, String endTime, String text) {
        this.index = index;
        this.startTime = startTime;
        this.endTime = endTime;
        this.text = text;
    }

    // 时间戳格式化
    public static String formatTimestamp(long ms) {
        long hours = ms / (1000 * 60 * 60);
        long minutes = (ms % (1000 * 60 * 60)) / (1000 * 60);
        long seconds = (ms % (1000 * 60)) / 1000;
        long millis = ms % 1000;

        return String.format("%02d:%02d:%02d,%03d", hours, minutes, seconds, millis);
    }

    @Override
    public String toString() {
        return index + "\n" + startTime + " --> " + endTime + "\n" + text;
    }
}
